import { defineStore } from 'pinia'
import type { ICollageGoods } from '@/types/type'

export const usecollageGoodsListStore = defineStore('collageGoodsList', {
    state() {
        return {
            //定义在拼团页面的变量，商品数据数组
            detailCollageList: [] as Array<ICollageGoods>,
            stateAll: true
        }
    },
    actions: {
        // 保存在store里面，收藏里面使用
        saveCollageGoods(detailCollageList: ICollageGoods) {
            //把接收传的collectionGoods实参，然后把它赋给collectionList
            this.detailCollageList.push(detailCollageList)
        },
        stateChange(){
             this.stateAll=false
        },
    },
    getters: {

    },
    persist: {
        enabled: true,//允许存储,默认trueimage.png
        strategies: [
            {
                key: 'detailCollageList',//存储的数据名字
                storage: localStorage,//保存的类型，默认是session,
                paths: ['detailCollageList'],//需要持久保存的state里面的数据
            },
        ],
    }
})
